package com.carleasoft.mps.core.utils;

import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

/**
 * <p>Description: 分页返回实体类</p>
 * @author haoyi
 */
public class PageResult<T> implements Serializable {
    /**
     * 总数
     */
    private long totalCount = 0;
    /**
     * 查询数据列表
     */
    private List<T> results = Collections.emptyList();

    public PageResult(){
    }

    public PageResult(long totalCount,List<T> results){
        this.totalCount = totalCount;
        if(!CollectionUtils.isEmpty(results)){
            this.results = results;
        }
    }

    public long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(long totalCount) {
        this.totalCount = totalCount;
    }

    public List<T> getResults() {
        return results;
    }

    public void setResults(List<T> results) {
        this.results = results;
    }

    @Override
    public String toString() {
        return "PageResult{" +
                "totalCount=" + totalCount +
                ", results=" + results +
                '}';
    }
}
